cmake_minimum_required(VERSION 3.20)

project(qrcode_detect)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

option(BUILD_DEB_PACKAGE "build deb package" OFF)

if(NOT CMAKE_BUILD_TYPE)
  set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE)
endif()

message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")

if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
  set(CMAKE_INSTALL_PREFIX ${CMAKE_CURRENT_BINARY_DIR}/install CACHE PATH "Force path to set CMAKE_INSTALL_PREFIX" FORCE)
endif(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)

message(STATUS "CMAKE_INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX}")
message(STATUS "CMAKE_SYSTEM_NAME: ${CMAKE_SYSTEM_NAME}")
message(STATUS "CMAKE_SYSTEM_PROCESSOR: ${CMAKE_SYSTEM_PROCESSOR}")

set(THIRD_PARTY_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR}/third_party)
set(THIRD_PARTY_BUILD_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR}/build_3rdparty)
set(THIRD_PARTY_DOWNLOAD_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR}/download_deps)

set(LIBHV_DIR ${THIRD_PARTY_BUILD_ROOT_DIR}/libhv)
message(STATUS "LIBHV_DIR: ${LIBHV_DIR}")

set(SPDLOG_DIR ${THIRD_PARTY_BUILD_ROOT_DIR}/spdlog)
message(STATUS "SPDLOG_DIR: ${SPDLOG_DIR}")

set(OPENCV_DIR ${THIRD_PARTY_BUILD_ROOT_DIR}/opencv_4.9.0)
set(OPENCV_SOURCE_DIR ${THIRD_PARTY_DOWNLOAD_ROOT_DIR}/opencv_4.9.0)
message(STATUS "OPENCV_DIR: ${OPENCV_DIR}")
message(STATUS "OPENCV_SOURCE_DIR: ${OPENCV_SOURCE_DIR}")

set(ZBAR_LIB_DIR ${THIRD_PARTY_BUILD_ROOT_DIR}/zbar)
message(STATUS "ZBAR_LIB_DIR: ${ZBAR_LIB_DIR}")

include(${CMAKE_CURRENT_LIST_DIR}/cmake/download_file.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/cmake/Utility.cmake)

set(QRCODE_DETECT_SERVER_VERSION "1.0.0")
message(STATUS "QRCODE_DETECT_SERVER_VERSION: ${QRCODE_DETECT_SERVER_VERSION}")

set(QRCODE_DETECT_SERVER_GIT_HASH "")
get_git_hash(QRCODE_DETECT_SERVER_GIT_HASH)
message(STATUS "QRCODE_DETECT_SERVER_GIT_HASH: ${QRCODE_DETECT_SERVER_GIT_HASH}")

set(QRCODE_DETECT_SERVER_GIT_BRANCH "")
get_git_branch(QRCODE_DETECT_SERVER_GIT_BRANCH)
message(STATUS "QRCODE_DETECT_SERVER_GIT_BRANCH: ${QRCODE_DETECT_SERVER_GIT_BRANCH}")

add_subdirectory(src)